package com.tanhua.server.service;

import com.easemob.im.server.api.user.UserApi;
import com.tanhua.dubbo.api.Userapi;
import com.tanhua.server.interceptor.Userthread;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class PhoneService {
    @Autowired
    private UserService userService;
    @Autowired
    RedisTemplate<String,String> redisTemplate;
    public void sendMsg() {
      String phone =  Userthread.getUser().getMobile();
      userService.sendMsg(phone);
    }

    public Boolean checkVerificationCode(String verificationCode) {
        String phone =  Userthread.getUser().getMobile();
      String redisCode = (String) redisTemplate.opsForValue().get("smsCode_"+phone);
      if(redisCode.equals(verificationCode)){
          return true;
      }
      return false;

    }

    public void changePhone(String phone) {
        userService.changePhone(phone);
    }
}
